home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-13 | 2.2 KB | 89 lines | [TEXT/EDIT] |
- -- Part of SmallEiffel -- Read DISCLAIMER file -- Copyright (C)
- -- Dominique COLNET and Suzanne COLLIN -- colnet@loria.fr
- --
- deferred class STD_FILE
- --
- -- Root class of :
- -- - STD_INPUT to read on the keyboard (known as `std_input').
- -- - STD_OUTPUT to write on the screen (known as `std_output').
- -- - STD_INPUT_OUTPUT to read/write on the keyboard/screen (known as `io').
- -- - STD_FILE_READ to read a named file on disk.
- -- - STD_FILE_WRITE to write a named file on disk.
- -- - CURSES interactive screen/cursor handling.
- -- - STD_ERROR to write on the error file (default is screen).
- --
- -- Note : a common list of feature (such as `put_character',
- -- `put_string', etc.) are shared by all classes so you can
- -- exchanges objects.
- -- For example, it easy to test writing on the screen (using
- -- `std_output') and then to use a named file (using
- -- STD_FILE_WRITE or `connect_to').
- --
-
- feature {ANY}
-
- path: STRING;
- -- Not Void when connected to the corresponding file on the disk.
-
- connect_to(new_path: STRING) is
- require
- not is_connected;
- path = Void;
- not new_path.empty;
- deferred
- end;
-
- disconnect is
- require
- is_connected;
- deferred
- end;
-
- is_connected: BOOLEAN is
- do
- Result := path /= Void;
- end;
-
- feature {NONE}
- --
- -- NOTE: use only a few basic external C calls.
- --
-
- mode: STRING;
-
- fopen(f: STRING; m: STRING): POINTER is
- require
- f /= Void;
- m /= Void
- local
- pf, pm: POINTER;
- do
- pf := f.to_external;
- pm := m.to_external;
- c_inline_c("R=(void*)fopen(((char*)_pf),((char*)_pm));");
- end;
-
- fclose(stream_pointer : POINTER): INTEGER is
- external "C"
- end;
-
- fputc(c: CHARACTER; stream_pointer: POINTER): CHARACTER is
- external "C"
- end;
-
- fgetc(stream_pointer : POINTER): CHARACTER is
- -- Result is of type CHARACTER because a int is a char !
- external "C"
- end;
-
- feof(stream_ptr: POINTER): BOOLEAN is
- do
- c_inline_c("R=feof((FILE*)C->_input_stream);");
- end;
-
- fflush(stream_pointer: POINTER): INTEGER is
- external "C"
- end;
-
- end -- STD_FILE
-